package com.tx.studentManager.dao;

import org.apache.commons.lang.StringUtils;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.tx.studentManager.qo.StudentQO;
import com.tx.studentManager.dao.base.HibernateGenericDao;
import com.tx.studentManager.model.Student;

@Repository
public class StudentDao extends HibernateGenericDao<Student, Integer,StudentQO>{

	@Override
	protected Criteria buildCriteria(Criteria criteria, StudentQO qo) {
		if (StringUtils.isNotBlank(qo.getClassId())) {
			criteria.createCriteria("studentClass").add(Restrictions.eq("classId", qo.getClassId()));
		}
		return criteria;
	}

}
